﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Collections.Generic;

public partial class Login : System.Web.UI.Page
{
	private UserComponent clsUserComponent;

	protected void Page_Load(object sender, EventArgs e)
	{
		clsUserComponent = new UserComponent();
	}

	protected void BtnLogin_OnClick(object sender, EventArgs e)
	{
		string strUsername;		// 登录用户名
		string strPassword;		// 登录密码
		User clsUser;		// 登录用户对象
		List<Column> listFirsColumns;		// 所有一级栏目List
		List<Column> listSecondColumns;		// 二级栏目List
		ColumnComponent clsColumnComponent;
		UserGroupComponent clsUserGroupComp;

		clsUserGroupComp = new UserGroupComponent();
		//clsUser = new User();
		clsColumnComponent = new ColumnComponent();
		strUsername = TxtUsername.Text.Trim();
		strPassword = TxtPassword.Text.Trim();
		clsUser = clsUserComponent.Login(strUsername, strPassword);

		if (clsUser != null)
		{
			Session["LoginUserID"] = clsUser.ID.ToString();
			Session["LoginUserRight"] = clsUserGroupComp.GetOneByID(clsUser.UserGroupID).UserGroupColumnsID;
			Session["LoginUserDepartmentID"] = clsUser.DepartmentID;

			PX.Expert.ExpertComponent clsExpertComp = new PX.Expert.ExpertComponent();

			clsExpertComp.SetExpertOnLine(clsUser.ID, Session.SessionID.ToString());

			Response.Redirect("Main.aspx");
		}
		else
		{
			//ShowMessageAlert.ShowMessage("用户名或密码错！");
			LabErrorMessage.Text = "用户名或密码错!";
		}
	}

}
